<template>
  <div class="main">
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="PieChart" style="width: 400px; height: 200px">基础饼图</div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {};
  },
  mounted() {

    var PieChart = echarts.init(document.getElementById("PieChart"));
    var PieChartOption = {
      title: {
        //设置图表的标题
        text: "饼图",
        subtext: "基础饼图",
        left: "center",
      },
      tooltip: {
        trigger: "item",
      },
      legend: {   //图表的
        orient: "vertical",
        left:"left",
      },
      series: [   
        {
          name: "Access From",
          type: "pie",
          radius: "30%",
          data: [
            { value: 1048, name: "Search Engine" },
            { value: 735, name: "Direct" },
            { value: 580, name: "Email" },
            { value: 484, name: "Union Ads" },
            { value: 300, name: "Video Ads" },
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)",
            },
          },
        },
      ],
    };
    PieChart.setOption(PieChartOption);
    // ===========================================================================================




    // ===========================================================================================

    window.addEventListener("resize", function () {
      PieChart.resize();
    });
  },
};
</script>
<style lang='less' scoped>
  .main{
    display: flex;
    flex-wrap: wrap;
  }
</style>